package com.lovely602.langchain4j.boot.controller.chat;


import dev.langchain4j.model.chat.ChatModel;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 受欢迎的整合模式
 *
 * @author lizhixing
 */
@RequestMapping(value = "/popular")
@RestController
public class PopularChatController {


    private final ChatModel chatModel;

    public PopularChatController(ChatModel chatModel) {
        this.chatModel = chatModel;
    }

    /**
     * 受欢迎的聊天
     */
    @GetMapping(value = "/chat")
    public String chat(@RequestParam(value = "msg", defaultValue = "hello", required = true) String msg) {
        return chatModel.chat(msg);
    }

}
